// 营销策略API封装
const BASE_URL = '/langchain-backend/market/marketing-strategies';

export const marketingStrategyApi = {
  // 获取营销策略列表，支持搜索
  getList: async (search: string = '') => {
    const url = search ? `${BASE_URL}?search=${encodeURIComponent(search)}` : BASE_URL;
    const res = await fetch(url, { method: 'GET', headers: { 'Accept': 'application/json' } });
    return await res.json();
  },
  // 新建营销策略
  create: async (data: any) => {
    const res = await fetch(BASE_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(data)
    });
    return await res.json();
  },
  // 更新营销策略
  update: async (id: string | number, data: any) => {
    const res = await fetch(`${BASE_URL}/${id}`, {
      method: 'PUT',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(data)
    });
    return await res.json();
  },
  // 删除营销策略
  delete: async (id: string | number) => {
    const res = await fetch(`${BASE_URL}/${id}`, {
      method: 'DELETE',
      headers: { 'Accept': 'application/json' }
    });
    return await res.json();
  }
}; 